New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@brainstack/log

Package Overview
Dependencies
Maintainers
0
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brainstack/log

A Micro Logger Package

  • 1.1.163
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
23
decreased by-66.18%
Maintainers
0
Weekly downloads
 
Created
Source

@brainstack/log

Description

@brainstack/log is a logging package that provides a flexible and customizable logger for your JavaScript or TypeScript projects. It allows you to manage log levels and integrate with various logging systems.

The package provides the following abstractions:

LoggerIntegration

Represents a logger integration that provides methods for logging messages at different levels.

  • log(message: any): void: Logs a general message.
  • info(message: any): void: Logs an informational message.
  • warn(message: any): void: Logs a warning message.
  • error(message: any): void: Logs an error message.
  • verbose(message: any): void: Logs a verbose message.

Logger

Represents a logger that manages log levels and integrations for logging messages.

  • integrations: LoggerIntegration[]: The logger integrations.
  • level: number: The current log level.
  • changeLogLevel(level: number): void: Changes the log level of the logger.
  • addIntegration(integration: LoggerIntegration): void: Adds a logger integration.
  • removeIntegration(integration: LoggerIntegration): void: Removes a logger integration.
  • log(message: any): void: Logs a message.
  • info(message: any): void: Logs an informational message.
  • warn(message: any): void: Logs a warning message.
  • error(message: any): void: Logs an error message.
  • verbose(message: any): void: Logs a verbose message.

Features

  • Flexible log level management.
  • Customizable logger integrations.
  • Supports logging at different levels: log, info, warn, error, verbose.

Getting Started

Installation

You can install the @brainstack/log package using npm:

npm install @brainstack/log

or yarn:

yarn add @brainstack/log

Usage

Here's an example of how to use the @brainstack/log package:

import { createLogger, consoleIntegration } from '@brainstack/log';

// Create a logger with a log level and integration
const logger = createLogger(3, [consoleIntegration]);

// Log messages at different levels
logger.log('This is a log message');
logger.info('This is an info message');
logger.warn('This is a warning message');
logger.error('This is an error message');
logger.verbose('This is a verbose message');

Use Case Walkthrough

Here's a walkthrough of a common use case for the @brainstack/log package:

  1. Install the package using npm or yarn.
  2. Import the necessary modules from @brainstack/log.
  3. Create a logger using the createLogger function, specifying the log level and any desired integrations.
  4. Use the logger to log messages at different levels using the provided methods (log, info, warn, error, verbose).

Contributing

Contributions to @brainstack/log are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request on the GitHub repository.

License

This package is licensed under the MIT License.

Keywords

FAQs

Package last updated on 11 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc